package com.superlc.ssm.modular.sys.model;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonView;
import com.superlc.ssm.core.common.jsonview.UserApiJsonView;

import java.io.Serializable;
import java.util.List;

/**
 * @author super
 */
@JsonIgnoreProperties({"password","salt"})
public class UserInfo implements Serializable {

    @JsonView(UserApiJsonView.class)
    private Integer uid;

    @JsonView(UserApiJsonView.class)
    private String username;

    @JsonView(UserApiJsonView.class)
    private String name;

    private String password;
    private String salt;
    private byte state;

    private List<SysRole> roleList;


    public Integer getUid() {
        return uid;
    }

    public void setUid(Integer uid) {
        this.uid = uid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public byte getState() {
        return state;
    }

    public void setState(byte state) {
        this.state = state;
    }

    public List<SysRole> getRoleList() {
        return roleList;
    }

    public void setRoleList(List<SysRole> roleList) {
        this.roleList = roleList;
    }

    /**
     * 密码盐.
     * @return
     */
    public String getCredentialsSalt(){
        return this.username+this.salt;
    }

    //没有set方法json转object时会失败
    public void setCredentialsSalt(String value){ }

    @Override
    public String toString() {
        return "UserInfo{" +
                "uid=" + uid +
                ", username='" + username + '\'' +
                ", name='" + name + '\'' +
                ", password='" + password + '\'' +
                ", salt='" + salt + '\'' +
                ", state=" + state +
                ", roleList=" + roleList +
                '}';
    }
}